import { observer } from "Mobx-react";
import SurveyItem from "./SurveyItem";
import { questionnaire } from "@/stores/questionnaire";
function SurveyList() {
  //显示关联
  const showConcern = (id: number) => {
    const controlLogic = questionnaire.controlLogic.find(item => item.childId === id);
    return questionnaire.logicText(controlLogic);
  };
  //获取当前项的选项关联
  const optionLogic = (id: number) => {
    return questionnaire.controlOption.filter(item => item.childId === id);
  };
  return (
    <>
      {questionnaire.question.map((item, index) => (
        <SurveyItem
          key={item.id}
          question={item}
          index={index}
          insertNum={questionnaire.insertNum}
          serialNum={questionnaire.serialNum(item.id).num}
          showConcern={showConcern(item.id)}
          optionLogic={optionLogic(item.id)}
        ></SurveyItem>
      ))}
    </>
  );
}

export default observer(SurveyList);
